package com.andova.camera.glsurface

import android.content.Context
import android.graphics.SurfaceTexture
import android.util.AttributeSet
import com.andova.face.ICameraCheckListener
import com.andova.face.IFaceDetector
import com.andova.face.detector.IPreview
import com.andova.glcamera.glsurface.CameraGLSurfaceView

class ACameraGLSurfaceView(context: Context, attrs: AttributeSet?) : CameraGLSurfaceView(context, attrs), IPreview {
    private val previewer: ACameraPreviewer by lazy { ACameraPreviewer(context, this, this) }
    override fun setFaceDetector(faceDetector: IFaceDetector?): IPreview? = previewer.setFaceDetector(faceDetector)
    override fun setCheckListener(checkListener: ICameraCheckListener?): IPreview? = previewer.setCheckListener(checkListener)
    override fun setMinCameraPixels(minCameraPixels: Long): IPreview? = previewer.setMinCameraPixels(minCameraPixels)
    override fun setDisplayOrientation(degree: Int): IPreview? = previewer.setDisplayOrientation(degree)
    override fun toggleDrawPreview(draw: Boolean): IPreview {
        TODO("Not yet implemented")
    }

    override fun closeCamera(): Unit = run { previewer.closeCamera() }
    override fun getCameraId(): Int = previewer.getCameraId()
    override fun setCameraId(cameraId: Int): IPreview? = previewer.setCameraId(cameraId)
    override fun release(): Unit = run { previewer.release() }
    override fun lazyCallback(millis: Long) {
        TODO("Not yet implemented")
    }

    override fun openCamera() = run { }
    override fun openCamera(callbackFrameData: Boolean) = run { }
    override fun openCamera(callbackFrameData: Boolean, frameRange: Int) = run { }
    override fun onSurfaceTextureCreated(surfaceTexture: SurfaceTexture?) {
        previewer.openCamera(surfaceTexture)
    }
}